<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Title</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=no"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta name="renderer" content="webkit">
    <link rel="stylesheet" href="../../mdui/css/mdui.min.css">
    <script defer src="../../mdui/js/mdui.min.js"></script>
    <script src="../../js/axios.min.js"></script>
    <script src="../../js/qs.min.js"></script>
    <script src="../../js/common.js"></script>
    <script src="../../js/vue.js"></script>
    <style>
        a {
            text-decoration: none;
        }

        .mdui-table {
            width: 700px;
            margin-top: 5px;
        }

        .mdui-table td {
            height: 20px;
            margin: 0;
            padding: 0;
        }

        .mdui-table th {
            height: 25px;
            margin: 0;
            padding: 0;
        }


        .mdui-table thead {
            height: 30px;
        }

        h5 {
            font-weight: normal;
            margin-bottom: 5px;
        }

        .t2 td {
            height: 40px;
        }

        .mdui-btn-dense {
            margin-top: 10px;
            width: 680px;
            height: 38px;
            margin-left: 10px;
        }

        .mdui-btn {
            height: 30px;
        }

    </style>
</head>
<body class="mdui-theme-primary-indigo mdui-theme-accent-green">
<div class="mdui-container-fluid" id="app">
    <h1 class="mdui-text-color-theme">安排维修</h1>
    <div style="width: auto">
        <h5>维修人员表</h5>
        <div style="margin-bottom: 8px;">
            工种: <input v-model="type" type="text" placeholder="">
            <button @click="findTechnician1" class="mdui-btn mdui-btn-raised mdui-ripple mdui-color-blue-700">查询
            </button>
            <button @click="reset" class="mdui-btn mdui-btn-raised mdui-ripple mdui-color-blue-700">重置</button>
        </div>
        <table class="mdui-table mdui-table-hoverable">
            <thead>
            <tr>
                <th>姓名</th>
                <th>工号</th>
                <th>电话</th>
                <th>工种</th>
            </tr>
            </thead>
            <tbody>
            <tr v-for="(t,index) in technicians">
                <td>{{t.name }}</td>
                <td>{{t.number}}</td>
                <td>{{t.phone}}</td>
                <td>{{t.type}}</td>
            </tr>
            </tbody>
        </table>

        <h5>维修安排</h5>
        <table class="mdui-table t2 mdui-table-hoverable">
            <tbody>
            <tr>
                <td>详情</td>
                <td>repair.detail</td>
            </tr>
            <tr>
                <td>维修员工号</td>
                <td><input class=" mdui-textfield-input1" type="text" v-model="number"/></td>
            </tr>
            </tbody>
        </table>
        <button class="mdui-btn mdui-btn-dense mdui-color-theme-accent mdui-ripple mdui-color-green-800"
                @click="addArrangment">
            提交
        </button>
    </div>
</div>
</body>

<script>
    let params = new URLSearchParams(location.search);//location.searc url中参数的部分包括问号
    let repairid = params.get("id")
    let vm = new Vue({
        el: '#app',
        data: {
            id: '',
            place: '',
            rapairs: [],
            technicians: [],
            repair: {
                id: '',
            },
            number: '',
            type: ''
        },
        created() {
            // this.findTechnician();
            this.findRepair();
        },
        methods: {
            reset() {
                this.type = ''
            },

            findTechnician1() {
                let _this = this
                axios.get("/technician/findByType?type=" + this.type)
                    .then(function (res) {
                        _this.technicians = res.data;
                        console.log(res.data)
                    })
            },

            addArrangment() {
                console.log(this.name)
                let _this = this
                axios.get("/maintenance/addarrangment", {
                    params: {
                        id: repairid,
                        number: _this.number
                    }
                })
                    .then(function (res) {
                        if (res.data) {
                            mdui.alert("安排成功")
                            window.location.href = "detail.html?id=" + repairid;
                        }
                    })
            },
            findTechnician() {
                let _this = this;
                axios
                    .get("/technician/list")
                    .then(function (res) {
                        _this.technicians = res.data;
                    })
            },


            findRepair() {
                let _this = this
                axios.get("/repair/findById?id=" + repairid)
                    .then(function (res) {
                        _this.repair = res.data;
                        console.log(res.data)
                    })
            },
        }
    })
</script>
</body>
</html>